<template>
    <div class="views-dianyingxinxi-detail">
        <div>
            <el-card class="box-card">
                <template #header>
                    <div class="clearfix">
                        <span class="title"> 电影信息详情 </span>
                    </div>
                </template>

                <el-descriptions class="margin-top" :column="3" border>
                    <el-descriptions-item label="电影编号"> {{ map.dianyingbianhao }} </el-descriptions-item>
                    <el-descriptions-item label="电影名称"> {{ map.dianyingmingcheng }} </el-descriptions-item>
                    <el-descriptions-item label="分类">
                        <e-select-view module="dianyingfenlei" :value="map.fenlei" select="id" show="fenleimingcheng"></e-select-view>
                    </el-descriptions-item>
                    <el-descriptions-item label="电影类型"> {{ map.dianyingleixing }} </el-descriptions-item>
                    <el-descriptions-item label="影票价格"> {{ map.yingpiaojiage }} </el-descriptions-item>
                    <el-descriptions-item label="上映地区"> {{ map.shangyingdiqu }} </el-descriptions-item>
                    <el-descriptions-item label="导演"> {{ map.daoyan }} </el-descriptions-item>
                    <el-descriptions-item label="主演"> {{ map.zhuyan }} </el-descriptions-item>
                    <el-descriptions-item label="语言"> {{ map.yuyan }} </el-descriptions-item>
                    <el-descriptions-item label="年份"> {{ map.nianfen }} </el-descriptions-item>
                    <el-descriptions-item label="片长"> {{ map.pianchang }} </el-descriptions-item>
                    <el-descriptions-item label="是否上架"> {{ map.shifoushangjia }} </el-descriptions-item>
                    <el-descriptions-item label="评分"> {{ map.pingfen }} </el-descriptions-item>
                    <el-descriptions-item label="销售票数"> {{ map.xiaoshoupiaoshu }} </el-descriptions-item>
                    <el-descriptions-item label="添加人"> {{ map.tianjiaren }} </el-descriptions-item>
                </el-descriptions>

                <el-descriptions direction="vertical" class="margin-top" :column="1" border>
                    <el-descriptions-item label="电影海报"> <e-images :src="map.dianyinghaibao" type="detail"></e-images> </el-descriptions-item>
                    <el-descriptions-item label="电影详情"> <div v-html="map.dianyingxiangqing"></div> </el-descriptions-item>
                </el-descriptions>

                <div class="no-print">
                    <el-button @click="$router.go(-1)">返回</el-button>
                    <el-button @click="$print">打印</el-button>
                </div>
            </el-card>
        </div>
    </div>
</template>

<script setup>
    import http from "@/utils/ajax/http";
    import DB from "@/utils/db";

    import { ref, reactive, watch } from "vue";
    import { useRoute } from "vue-router";
    import { session } from "@/utils/utils";
    import { extend } from "@/utils/extend";
    import { useDianyingxinxiFindById, canDianyingxinxiFindById, useDianyingxinxishoucang, canShoucangInsert, useShoucangCreateForm } from "@/module";

    const route = useRoute();

    // 获取详情页面的一行数据,当url参数id变更时，自动
    const map = useDianyingxinxiFindById(route.query.id);
    // 当url参数id变更时，自动更新map中的数据
    watch(
        () => route.query.id,
        (id) => {
            canDianyingxinxiFindById(id).then((res) => {
                extend(map, res);
            });
        }
    );
    // end 获取详情页面的一行数据
    // 获取当前收藏信息
    const { is_shoucang, shoucangCount } = useDianyingxinxishoucang(route.query.id);
    watch(
        () => route.query.id,
        (id) => {
            useDianyingxinxishoucang(id, is_shoucang, shoucangCount);
        },
        { immediate: true }
    );
    // end 获取当前收藏信息

    var shoucangForm = useShoucangCreateForm();
    const onShoucangChange = async () => {
        var f = shoucangForm.form;
        f.xwid = route.query.id;
        f.biao = "dianyingxinxi";
        f.biaoti = map.dianyingmingcheng;
        var s = await canShoucangInsert(f);
        useDianyingxinxishoucang(route.query.id, is_shoucang, shoucangCount);
    };
</script>

<style scoped lang="scss">
    .views-dianyingxinxi-detail {
    }
</style>
